Ext.onReady(function(){
	var arrYesNo = [[0,'否'],[1,'是']];
	var yesNo = new Ext.data.SimpleStore({fields:['value','option'],data: arrYesNo});
	//define combox tree
	var comboxWithTree = new Ext.form.ComboBox({
		store:new Ext.data.SimpleStore({fields:[],data:[[]]}),
		editable:false,
		fieldLabel: '项目名称1',
		shadow:false,
		mode: 'local',
		triggerAction:'all',
		maxHeight: 200,
		tpl: '<tpl for="."><div style="height:200px"><div id="tree1"></div></div></tpl>',
		selectedClass:'',
		onSelect:Ext.emptyFn
	});
	comboxWithTree.on('expand',function(){
		tree1.render('tree1');
  	});
	var tree1 = new Ext.tree.TreePanel({
			loader: new Ext.tree.TreeLoader({dataUrl:basePath+'demo/getnodes.jsp'
		}),
		rootVisible:false,
		border:false,
 		root:new Ext.tree.AsyncTreeNode({text: '电网发展',id:'0'})
  	});
  	
  	tree1.on('click',function(node){
  		comboxWithTree.setValue(node.text);
  		comboxWithTree.collapse();
  	});
  	tree1.on("beforeload",function(node){
       		node.loader = new Ext.tree.TreeLoader({
       				dataUrl:basePath+'demo/getnodes.jsp?pid='+node.id
               }) 
       },this,true);
    //end define combox tree 
	//define action
	var sb_Action = new Ext.Action({   
	    text: text_sb_action,   
	    handler: function(){   
	        Ext.Msg.alert('有情提示', '您点到我了！哈哈哈哈哈哈哈哈哈哈哈.');   
	    },   
	    iconCls: 'sb'  
	});
	var save_action = new Ext.Action({   
	    text: text_save_action,   
	    handler: function(){   
	        Ext.Msg.alert('有情提示', '您点到我了！哈哈哈哈哈哈哈哈哈哈哈.');   
	    },   
	    iconCls: 'save'  
	});
	var del_action = new Ext.Action({   
	    text: text_del_action,   
	    handler: function(){   
	        Ext.Msg.alert('有情提示', '您点到我了！哈哈哈哈哈哈哈哈哈哈哈.');   
	    },   
	    iconCls: 'delete'  
	});
	
	 var tabs = new Ext.FormPanel({
        border:false,
        layout:'fit',
        fill:true,
        items: [{
            xtype:'tabpanel',
            activeTab: 0,
			enableTabScroll:true,
			autoScroll:true,
			height:600,
            defaults:{bodyStyle:'padding:10px'},
            items:[{
	                title:tab_jbxx,
	                layout: 'column',
	                labelWidth: 80,
	                bodyStyle:'padding: 4px',
	                border:false,
	                autoScroll:true,
	                items:[{
				      title:'基本信息',
				      xtype:'fieldset',
				      collapsible:false,
				      width:'98%',
				      items: [{
						layout: 'column',
						border:false,
						items:[{
							columnWidth: .5,
							layout: 'form',
							labelWidth: 80,
							border:false,
							bodyStyle:'padding:5px 5px 0',
							items: [{xtype:'textfield',fieldLabel: '项目名称',id:'textMeasureName',anchor:'95%', width:'100%'}]
						},{
							columnWidth: .5,
							layout: 'form',
							labelWidth: 80,
							border:false,
							bodyStyle:'padding:5px 5px 0',
							items: [comboxWithTree]
						}]
					}//end of the first line
					,
					{
						layout: 'column',
						border:false,
						items:[{
							columnWidth: .5,
							layout: 'form',
							labelWidth: 80,
							border:false,
							bodyStyle:'padding:5px 5px 0',
							items: [{xtype:'textfield',fieldLabel: '项目名称3',id:'textMeasureName3',anchor:'95%', width:'100%'}]
						},{
							columnWidth: .25,
							layout: 'form',
							labelWidth: 80,
							border:false,
							bodyStyle:'padding:5px 5px 0',
							items: [new Ext.form.ComboBox({store: yesNo,displayField:'option',valueField:'value',mode: 'local',resizable: false, fieldLabel:'是否分布存储', id:'combMeasureSaveMode', width:100, triggerAction: 'all'})]
						},
						{
							columnWidth: .25,
							layout: 'form',
							labelWidth: 80,
							border:false,
							bodyStyle:'padding:5px 5px 0',
							items: [new Ext.form.ComboBox({store: yesNo,displayField:'option',valueField:'value',mode: 'local',resizable: false,hideLabel:true, fieldLabel:'是否分布存储3', id:'combMeasureSaveMode3', width:100, triggerAction: 'all'})]
						}]
					}
					,{
						layout: 'form',
						border:false,
						bodyStyle:'padding:5px 5px 0 5px',
						labelAlign: 'top',
						items: [{xtype:'textarea', fieldLabel: '指标描述', id: 'textMeasureDesc', height:'100', width:'100%'}]
					},{
						layout: 'form',
						border:false,
						bodyStyle:'padding:5px 5px 0 5px',
						labelAlign: 'top',
						items: [{xtype:'textarea', fieldLabel: '指标描述2', id: 'textMeasureDesc2', height:'300', width:'100%'}]
					}]
			  } //end of fieldset
		    ]
	    }
            //add tabs here 
            ,{
                title:tab_kyxx,
                layout:'form',
                defaults: {width: 230},
                defaultType: 'textfield',

                items: [{
                    fieldLabel: 'Home',
                    name: 'home',
                    value: '(888) 555-1212'
                },{
                    fieldLabel: 'Business',
                    name: 'business'
                },{
                    fieldLabel: 'Mobile',
                    name: 'mobile'
                },{
                    fieldLabel: 'Fax',
                    name: 'fax'
                }]
            },{
                title:tab_wbtj,
                layout:'form',
                defaults: {width: 230},
                defaultType: 'textfield',
                items: [{
                    fieldLabel: 'Home',
                    name: 'home',
                    value: '(888) 555-1212'
                },{
                    fieldLabel: 'Business',
                    name: 'business'
                },{
                    fieldLabel: 'Mobile',
                    name: 'mobile'
                },{
                    fieldLabel: 'Fax',
                    name: 'fax'
                }]
            },{
                title:tab_pfwj,
                layout:'form',
                defaults: {width: 230},
                defaultType: 'textfield',

                items: [{
                    fieldLabel: 'Home',
                    name: 'home',
                    value: '(888) 555-1212'
                },{
                    fieldLabel: 'Business',
                    name: 'business'
                },{
                    fieldLabel: 'Mobile',
                    name: 'mobile'
                },{
                    fieldLabel: 'Fax',
                    name: 'fax'
                }]
            }
            ]}]
    });

	//define right space
	var panel = new Ext.Panel({   
	    title: '电网发展/新增项目',   
	    width:'100%',   
	    height:'auto',
	    iconCls:'title',
	    region:'center',
	    tbar: [   
	    	//将action做为一个菜单按钮添加到工具栏   
	        '-',sb_Action,'-',save_action,'-',del_action,'-'
	    ],   
	    items: [
	       tabs
	    ]  
	});
	
	//define left tree 
	  var xmb_root = new Ext.tree.AsyncTreeNode({text:text_xmb});
      var xmb_tree = new Ext.tree.TreePanel({
                        id:'im-tree',
                        title: text_xmb,
                        width:200,
                        minSize: 175,
	                    maxSize: 400,
	                    collapsible: true,
                        region:'west',
                        loader: new Ext.tree.TreeLoader({dataUrl:basePath+'inc/dwfz.json'}),
                        rootVisible:true,
                        lines:false,
                        iconCls:'xmb',
                        autoScroll:true,
                        root: xmb_root
        });
       xmb_root.expand();
       xmb_tree.on('click',function(node,e){
       		//
       	});
	//define viewport 
    var viewport = new Ext.Viewport({
             layout:'border',
             items:[
               xmb_tree ,panel
             ]
        });
});